<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    function total(h, n) {
        var sum = 0;
        for (var i = 1; i <= n; i++) {
            if (i <= 2) {
                h = 100;
                sum += h;
                console.log(h);
            } else if (i >= 3) {
                h = h / 2;
                sum += h;
                console.log(h);
            }
        }
        return sum;
    }
    var sum = total(100, 2);
    console.log(sum)
</script>

</html>